/*
 * Copyright 2008 [rapid-framework], Inc. All rights reserved.
 * Website: http://www.rapid-framework.org.cn
 */

    define("pages/jls_yzdj/form", [
            '../../pages/jls_yzdj/YzdjForm.html.js',
            "../../common/componts",
        ],
        function(require){
            var _show=function(_title,_data){
                var comonts=require("../../common/componts");
                var tmp= require("../../pages/jls_yzdj/YzdjForm.html");
                var htmlcompile = template.compile(tmp);
                //var _blr=loginuser.username;//获取当前办理人
                var html = htmlcompile(
                    {
                        title:"验证登记",
                        data:_data
                    });
                $("#dlgZrs").dialog('destroy');
                $("#dlgYzdj").dialog('destroy');
                $("#yzdjForm").html(html);
                comonts.initSelect(undefined,undefined,undefined);
                $.parser.parse($("#yzdjForm").parent());
                var testTypes = [{id: '1', value: '身份证'},
                    {id: '2', value: '暂住证'},
                    {id: '3', value: '户口簿'},
                    {id: '4', value: '军官证'},
                    {id: '5', value: '警官证'},
                    {id: '6', value: '士兵证'},
                    {id: '7', value: '护照'},
                    {id: '8', value: '无证件'},
                    {id: '9', value: '其他证件'},];
                $('#testType').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: testTypes
                });
                var xbtype = [{id: '1', value: '未知的性别'},
                    {id: '2', value: '男性'},
                    {id: '3', value: '女性'},
                    {id: '4', value: '未说明的性别'},];
                $('#xbtype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: xbtype
                });
                var mztype = [{id: '1', value: '汉'},
                    {id: '2', value: '蒙古'},
                    {id: '3', value: '回'},
                    {id: '4', value: '藏'}];
                $('#mztype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: mztype
                });
                var hyzktype = [{id: '1', value: '未婚'},
                    {id: '2', value: '已婚'},
                    {id: '3', value: '丧偶'},
                    {id: '4', value: '离婚'},
                    {id: '5', value: '其他'},];
                $('#hyzktype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: hyzktype
                });
                var hjdTypes = [{id: '1', value: '北京市'},
                    {id: '2', value: '北京市辖区'},];
                $('#hjd').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: hjdTypes
                });
                var xzdTypes = [{id: '1', value: '北京市'},
                    {id: '2', value: '北京市辖区'},];
                $('#xzd').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: xzdTypes
                });
                var whcdtype = [{id: '1', value: '研究生'},
                    {id: '2', value: '研究生毕业'},
                    {id: '3', value: '研究生肆业'},];
                $('#whcdtype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: whcdtype
                });
                var sfTypes = [{id: '1', value: '国家公务员'},
                    {id: '2', value: '企事业管理人员'},];
                $('#sf').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: sfTypes
                });
                var zcTypes = [{id: '1', value: '驾车'},
                    {id: '2', value: '驾船'},];
                $('#zc').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: zcTypes
                });
                var gjtype = [{id: '1', value: '中国'},
                    {id: '2', value: '中国台湾'},];
                $('#gjtype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: gjtype
                });
                var jgtype = [{id: '1', value: '北京市'},
                    {id: '2', value: '北京市辖区'},];
                $('#jgtype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: jgtype
                });
                var zzmmtype = [{id: '1', value: '中国共产党党员'},
                    {id: '2', value: '预备党员'},];
                $('#zzmmtype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: zzmmtype
                });
                var tssftype = [{id: '1', value: '人大代表'},
                    {id: '2', value: '政协委员'},];
                $('#tssftype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: tssftype
                });
                var zytype = [{id: '1', value: '国家机关，党群组织，企业，事业单位负责人'},
                    {id: '2', value: '中国共产党中央委员会和地方各级组织负责人'},];
                $('#zytype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: zytype
                });
                var azbtype = [{id: '1', value: '有'},
                    {id: '2', value: '没有'},];
                $('#azbtype').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: azbtype
                });
                var wfxw = [{id: '1', value: '违反治安管理案件'},
                    {id: '2', value: '扰乱公共秩序案件'},];
                $('#wfxw').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: wfxw
                });
                var xhay = [{id: '1', value: '扰乱公共秩序'},
                    {id: '2', value: '扰乱单位秩序'},];
                $('#xhay').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: xhay
                });
                var rjyy= [{id: '1', value: '行政拘留'},
                    {id: '2', value: '司法拘留'},];
                $('#rjyy').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: rjyy
                });
                var badw= [{id: '1', value: '上海市公安局'},
                    {id: '2', value: '上海市公安局国内安全保卫局'},];
                $('#badw').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: badw
                });
                var badwlx= [{id: '1', value: '公安机关'},
                    {id: '2', value: '检察院'},];
                $('#badwlx').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: badwlx
                });
                var zrdw= [{id: '1', value: '上海市公安局'},
                    {id: '2', value: '上海市公安局国内安全保卫局'},];
                $('#zrdw').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: zrdw
                });
                var sjpz= [{id: '1', value: '公安行政处罚决定书'},
                    {id: '2', value: '人民法院拘留决定书'},];
                $('#sjpz').combobox({
                    valueField: 'id',
                    textField: 'value',
                    panelHeight: 'auto',
                    editable: false,
                    data: sjpz
                });
               /* $('#cccd').layout();*/
                $("#jbxxclick").click(function () {

                    var sss=$("#jbxxlr").css("display");
                    if($("#jbxxlr").css("display")=='none'){
                        $("#jbxxlr").css("display","block");
                    }else if($("#jbxxlr").css("display")=='block'){
                        $("#jbxxlr").css("display","none");
                    }
                })
                $("#wfxwclick").click(function () {

                    var sss=$("#wfxwxxlr").css("display");
                    if($("#wfxwxxlr").css("display")=='none'){
                        $("#wfxwxxlr").css("display","block");
                    }else if($("#wfxwxxlr").css("display")=='block'){
                        $("#wfxwxxlr").css("display","none");
                    }
                });
                $("#wfxwclicks").click(function () {

                    var sss=$("#wfxwxxlrs").css("display");
                    if($("#wfxwxxlrs").css("display")=='none'){
                        $("#wfxwxxlrs").css("display","block");
                    }else if($("#wfxwxxlrs").css("display")=='block'){
                        $("#wfxwxxlrs").css("display","none");
                    }
                })

                $('#dlgYzdj').window('open');
                bindAction();
            }
            var saveYzdj=function () {
                var validate=$("#dlgYzdj").form('validate');
                if (validate) {
                    var data =$("#fmYzdj").serialize();
                    submitLoad();
                    $.ajax({
                        type : "POST",  //提交方式
                        url : "/jls_yzdj/yzdjAdd",//路径
                        data : data,//数据，这里使用的是Json格式进行传输
                        success : function(result) {
                            if (result.success) {
                                $('#dlgYzdj').dialog('close');
                                findYzdj();
                                $.messager.alert('提示','保存成功!','info');
                            }else{
                                removeLoad();
                                $.messager.alert('提示',result.msg,'info');
                            }
                        },
                        complete:function(){
                            removeLoad();
                        },

                    });
                }else{
                    $.messager.alert("提示", '必填项不能为空！');
                }
            }
            var updateYzdj=function () {
                var validate=$("#dlgYzdj").form('validate');
                if (validate) {
                    var data =$("#fmYzdj").serialize();
                    submitLoad();
                    $.ajax({
                        type : "POST",  //提交方式
                        url : "/jls_yzdj/yzdjUpdate",//路径
                        data : data,//数据，这里使用的是Json格式进行传输
                        success : function(result) {
                            if (result.success) {
                                $('#dlgYzdj').dialog('close');
                                findYzdj();
                                $.messager.alert('提示','更新成功!','info');
                            }else{
                                removeLoad();
                                $.messager.alert('提示',result.msg,'info');
                            }
                        },
                        complete:function(){
                            removeLoad();
                        },

                    });
                }else{
                    $.messager.alert("提示", '必填项不能为空！');
                }
            }
            var bindAction=function(){
                var yzdjId=$("#idfm").val();
                $("#yzdj_save").on("click",function(){
                    if(yzdjId==""||yzdjId==null){
                        saveYzdj();
                    }else {
                        updateYzdj();
                    }
                });
                $("#yzdj_cancel").on("click",function(){
                    $("#dlgYzdj").dialog("close");
                });

            }
            function findYzdj(){
                $('#yzdjId').datagrid('clearSelections');
                $('#yzdjId').datagrid('reload',{
                });
            }

            return{
                show:_show
            }
        });
